package com.syj.web.controller;

import com.syj.web.model.Comment;
import com.syj.web.service.CommentService;
import com.syj.web.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by rankawin on 2017/2/12.
 */
@Controller
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @Autowired
    private CommentService commentService;

    @RequestMapping(value = "/{productId}", method = RequestMethod.GET)
    public String selectById(@PathVariable Integer productId, ModelMap map) {
        map.put("product", productService.selectByPrimaryKey(productId));
        Comment comment = new Comment();
        comment.setProductId(productId);
        map.put("comment", commentService.select(comment));
        return "user_product";
    }
}
